﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;


public class AnimatorButton: Button
{
    public Animator animatorButton;
    public string Normal = "Normal";
    public string MouseUp = "MouseUp";
    public string MouseDown = "MouseDown";
    public string MouseEnter = "MouseEnter";

    public override void OnPointerDown(PointerEventData eventData)
    {
        base.OnPointerDown(eventData);
        if (eventData.button == PointerEventData.InputButton.Left)
        {
            if (!string.IsNullOrEmpty(MouseDown))
            {
                animatorButton.Play(MouseDown);
            }

        }
    }
    public override void OnPointerUp(PointerEventData eventData)
    {
        base.OnPointerUp(eventData);
        if (eventData.button == PointerEventData.InputButton.Left)
        {
            if (!string.IsNullOrEmpty(MouseUp))
            {
                animatorButton.Play(MouseUp);
            }
        }
    }
    public override void OnPointerExit(PointerEventData eventData)
    {
        base.OnPointerExit(eventData);
        if (!string.IsNullOrEmpty(Normal))
        {
            animatorButton.Play(Normal);
        }
    }


    public override void OnPointerEnter(PointerEventData eventData)
    {
        base.OnPointerEnter(eventData);
        if (!string.IsNullOrEmpty(MouseEnter))
        {
            animatorButton.Play(MouseEnter);
        }
    }
}

